package com.wangziyu.facerecognitiongate

import android.app.Service
import android.content.Intent
import android.os.IBinder
import com.wangziyu.facerecognitiongate.task.FaceTask
import com.wangziyu.facerecognitiongate.task.SyncTask
import com.wangziyu.facerecognitiongate.task.TaskManager
import com.wangziyu.facerecognitiongate.task.UpdateTask

/**
 * @description 负责所有task的调度和ui更新事件调度
 * @author wzy
 * @date 2025/08/10 02:15:50
 */
class CoreService : Service() {

    lateinit var taskManager: TaskManager

    override fun onCreate() {
        super.onCreate()
        taskManager.addTask(UpdateTask())
        taskManager.addTask(SyncTask())
        taskManager.addTask(FaceTask())
        startTasks()
    }

    override fun onDestroy() {
        super.onDestroy()
        stopTasks()
    }

    private fun startTasks() {
        taskManager.startAll()
    }

    private fun stopTasks() {
        taskManager.cancelAll()
    }

    override fun onBind(intent: Intent?): IBinder? {
        return null
    }
}